<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Grom Hellscream
 * Date: 11/2/12
 * Time: 11:33 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.mootools');

$document = JFactory::getDocument();
$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/autocomplete/meio.aucomplete.css');
$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/css/jquery.autocomplete.css');
$document->addStyleSheet(JURI::root() . 'components/com_vast/assets/css/thickbox.css');

$document->addScript(JURI::root() . 'components/com_vast/assets/autocomplete/Builder.js');

$document = JFactory::getDocument();
$autocompleteDir = JURI::root() . '/components/com_vast/assets/autocomplete/';

$tongiaoJSON = $this->get('tongiaoJSON');
$dantocJSON = $this->get('dantocJSON');

$script=<<<AUTOCOMPLETE
    Builder.build('{$autocompleteDir}', {
        Source: [
            'BGIFrame',
            'Meio.Autocomplete'
        ]
    });
    window.addEvent('domready', function() {
        var data = [
            {$tongiaoJSON}
        ];

        var instance = new Meio.Autocomplete($('jform_tongiao'), data, {
            selectOnTab: false,
            onNoItemToList: function(elements){
                elements.field.node.highlight('#ff0000');
            },
            filter: {
                type: 'contains',
                path: 'text'
            }
        });        
    });
    
    window.addEvent('domready', function() {
        var data = [
            {$dantocJSON}
        ];

        var instance = new Meio.Autocomplete($('jform_dantoc'), data, {
            selectOnTab: false,
            onNoItemToList: function(elements){
                elements.field.node.highlight('#ff0000');
            },
            filter: {
                type: 'contains',
                path: 'text'
            }
        });        
    });    
AUTOCOMPLETE;

$document->addScriptDeclaration($script);

$item = $this->get('item');
$phongs = $this->get('phong');
if (count($phongs) > 1) 
    $phong = $phongs[0];
elseif (count($phongs) == 1)
    $phong = $phongs;
$donvis = $this->get('donvi');
if (count($donvis) > 1)
    $donvi = $donvis[0];
elseif (count($donvis) == 1)
    $donvi = $donvis;
$khoi = $this->get('khoi');
$hosocanbo = VastHelper::getHosocanbo();
if (!JFactory::getUser()->authorise('vast.hosocanbo.edit', 'com_vast') && !(JFactory::getUser()->authorise('vast.hosocanbo.edit.own') && $hosocanbo != NULL && $hosocanbo->nguoidung_id == JFactory::getUser()->id))
{
    JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_vast&view=vast'));                        
}
?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Cơ cấu tổ chức</span> »
        <?php if (isset($khoi)): ?>        
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=donvitructhuoc&id=' . $khoi->id); ?>"><?php echo $khoi->ten ?></a> »                
        <?php endif; ?>
        <?php if (isset($donvi)): ?>
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=phongtructhuocs&id=' . $donvi->id); ?>"><?php echo $donvi->ten ?></a> »
        <?php endif; ?>
        <?php if (isset($phong)): ?>
        <span><?php echo $phong->ten; ?></span> »        
        <?php endif; ?>
        <span><?php echo $item['hoten']; ?></span>
    </div>
</div>

<div id="main" class="home">
    <h3 class="title green">Cập nhật thông tin cho cán bộ <?php echo $item['hoten']; ?></h3>
    
    <div class="form">
        <form class="commentform" action="<?php echo JRoute::_('index.php?option=com_vast&view=hosocanbo&layout=edit&id=' . $item['id']); ?>" method="post" id="hosocanbo" name="hosocanbo">
            
            <div class="row">
                <?php echo $this->form->getLabel('id'); ?>
                <?php echo $this->form->getInput('id'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('nguoidung_id'); ?>
                <?php echo $this->form->getInput('nguoidung_id'); ?>
            </div>

            <div class="row">
                <?php echo $this->form->getLabel('hoten'); ?>
                <?php echo $this->form->getInput('hoten'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('gioitinh'); ?>
                <?php echo $this->form->getInput('gioitinh'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('ngaysinh'); ?>
                <?php echo $this->form->getInput('ngaysinh'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('taikhoandientu'); ?>
                <?php echo $this->form->getInput('taikhoandientu'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('sohieu'); ?>
                <?php echo $this->form->getInput('sohieu'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('chungminhnhandan'); ?>
                <?php echo $this->form->getInput('chungminhnhandan'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('ngaycap'); ?>
                <?php echo $this->form->getInput('ngaycap'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('noicap'); ?>
                <?php echo $this->form->getInput('noicap'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('masothue'); ?>
                <?php echo $this->form->getInput('masothue'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('noisinh'); ?>
                <?php echo $this->form->getInput('noisinh'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('nguyenquan'); ?>
                <?php echo $this->form->getInput('nguyenquan'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('diachihientai'); ?>
                <?php echo $this->form->getInput('diachihientai'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('dienthoai'); ?>
                <?php echo $this->form->getInput('dienthoai'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('didong'); ?>
                <?php echo $this->form->getInput('didong'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('thudientu'); ?>
                <?php echo $this->form->getInput('thudientu'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('dantoc'); ?>
                <?php echo $this->form->getInput('dantoc'); ?>
            </div>
            
            <div class="row">
                <?php echo $this->form->getLabel('tongiao'); ?>
                <?php echo $this->form->getInput('tongiao'); ?>
            </div>
            
            <div class="row">
                <input type="hidden" name="option" value="com_vast" />
                <input type="hidden" name="task" value="hosocanbo.update" />
            </div>
            
            <div class="row buttons">
                <button type="submit" class="button" id="submit"><?php echo JText::_('Cập nhật'); ?></button>
                <?php echo JHtml::_('form.token'); ?>
            </div>
        </form>
    </div>
</div>